package com.example.fx.order

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.base.mvvm.BaseFragment
import com.example.fx.R
import com.example.fx.adapter.OrderPayAdapter
import com.example.fx.databinding.FragmentPayingBinding


class PayingFragment : BaseFragment<OrderViewModel,FragmentPayingBinding>() {
    lateinit var orderPayAdapter: OrderPayAdapter
    override fun getLayout(): Int  = R.layout.fragment_paying

    override fun getViewModel(): Class<OrderViewModel>  = OrderViewModel::class.java

    override fun initView() {
        orderPayAdapter = OrderPayAdapter()
        binding.rv.adapter = orderPayAdapter
        binding.rv.layoutManager = LinearLayoutManager(context)
        viewModel.orderlist("0",1,10)
    }

    override fun initData() {
        viewModel.listSuccess.observe(this){
            if(it.code==200){
                orderPayAdapter.data.clear()
                it.data.list.forEach {
                    orderPayAdapter.data.addAll(it.orderInfoList)
                }
                orderPayAdapter.notifyDataSetChanged()
            }
        }
    }

}